/**
 * Created by Administrator on 2017/6/12.
 */
$(function(){
    //页面刷新加载车票信息
    console.log(localStorage.StartLgy);
    console.log(localStorage.endLgy);
    console.log(localStorage.godateLgy);
    console.log(localStorage.goTimeFirstLgy);
    console.log(localStorage.goTimeLastLgy);
    console.log(localStorage.carInitialsChooseLgy);
    $('#start_seat').text(localStorage.StartLgy);
    $('#end_seat').text(localStorage.endLgy);
    $('.Date').text(localStorage.godateLgy);
    var obj={
        start:localStorage.StartLgy,
        end:localStorage.endLgy,
        godate:localStorage.godateLgy,
        goTimeFirst:localStorage.goTimeFirstLgy,
        goTimeLast:localStorage.goTimeLastLgy,
        carInitialsChoose:localStorage.carInitialsChooseLgy
    };
    $.ajax({
        type:"post",
        url:"/lookupTicket",
        data:obj,
        success:function(date){
            var html="";
            for(var i=0;i<date.length;i++){
                html+='<li class="ui-border-t" hehe='+date[i].id+'>'+
                    '<ul class="ui-tiled">'+
                    '<li><div class="ui-flex ui-flex-pack-start">'+date[i].carName+'</div><i style="color:gray">余票:<span>'+date[i].conut+'</span>张</i></li>'+
                '<li><div class="ui-flex ui-flex-pack-start"><div>始</div><div>'+date[i].startName+'</div></div><i><span>'+date[i].goTime+'</span>:00</i></li>'+
                '<li><div class="ui-flex ui-flex-pack-start myRow"><img src="../img/myRow.png" alt="row"/></div></li>'+
                '<li><div class="ui-flex ui-flex-pack-start"><div style="background-color: green">终</div><div>'+date[i].endName+'</div></div><i style="color: transparent">1</i></li>'+
                '</ul>'+
                '</li>';
            }
            $('.mainUl').html(html);
        }
    });


    //点击对应的车票，跳转到确认订单页面
    (function(){
       $(document).on('tap','.mainUl>li',function(){
           var id=$(this).attr("hehe");
           localStorage.setItem("ticktId",id);
           location.href="./ConfirmOrder.html";
       })
    })()
});
